
/**延迟函数 */
export const delay = (interval) => {
  typeof interval != 'number' ? interval = 100 : null;
  return new Promise(resolve => {
    setTimeout(() => {
      resolve()
    }, interval)
  })
}
/**blobToArrayBuffer */
export const blobToArrayBuffer = (blob) => {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      const arrayBuffer = e.target.result;
      resolve(arrayBuffer);
    };
    reader.onerror = (e) => {
      reject(e);
    }
    reader.readAsArrayBuffer(blob);
  })
}
/**blobToBase64 */
export const blobToBase64 = (blob) => {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();

    reader.onload = (e) => {
      resolve(e.target.result);
    }
    reader.onerror = (e) => {
      reject(e);
    }
    reader.readAsDataURL(blob);
  });
}
/**blobToObjectUrl */
export const blobToObjectUrl = (blob) => {
  const objectUrl = URL.createObjectURL(blob);
  setTimeout(() => { URL.revokeObjectURL(objectUrl); })

  return objectUrl
}